package com.neusoft.chatserver.controller;


import com.neusoft.chatserver.dto.RespBean;
import com.neusoft.chatserver.service.IUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author liuxp
 * @since 2021-07-14
 */
@CrossOrigin
@RestController
@RequestMapping("/chat")
public class UsersController {

    @Autowired
    IUsersService iUsersService;

    @GetMapping("/setUserOnline")
    public RespBean setUserOnline(int id) {
        List<Integer> list = iUsersService.setUserOnline(id);
        return RespBean.ok(200, "set success", list);
    }

    @GetMapping("/setUserOffline")
    public RespBean setUserOffline(int id) {
        List<Integer> list = iUsersService.setUserOffline(id);
        return RespBean.ok(200, "set success", list);

    }

    @PostMapping("/getUserOnlineStatus")
    public RespBean getUserOnlineStatus(@RequestBody List<Integer> ids) {
        List<Integer> userOnlineStatus = iUsersService.getUserOnlineStatus(ids);
        return RespBean.ok(200, "get useronline", userOnlineStatus);
    }
}

